package com.admin.application;

import com.admin.domain.modle.Advert;
import com.admin.domain.repository.AdvertRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;


/**
 * description
 * User: WeiDa
 * Date: 2017-4-11
 * Time: 16:45
 */
@Service
public class AdvertService {

    private static final Logger LOGGER = LoggerFactory.getLogger(AdvertService.class);
    @Autowired
    protected AdvertRepository advertRepository;

    public Advert create(Advert advert) {
        advert.setId(UUID.randomUUID().toString());
        advertRepository.add(advert);
        return advert;
    }

    public Advert modify(Advert advert) {
        advertRepository.update(advert);
        return advert;
    }

    public Advert get(String code) {
        return advertRepository.get(code);
    }

    public List<Advert> list(String key) {
        return advertRepository.list(key);
    }

    public void delete(String code) {
        advertRepository.remove(code);
    }


}
